package com.springboot2.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private String code;
    private String msg;
    private Object data;

    public static Result success(Object data){
         Result result = new Result();
         result.setCode("200");
         result.setMsg("成功");
         result.setData(data);
         return  result;
    }
    public static Result success(){
        Result result = new Result();
        result.setCode("200");
        result.setMsg("成功");
        result.setData(null);
        return  result;
    }

    public static Result error(String code,String msg,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return  result;
    }

    public static Result error(){
        Result result = new Result();
        result.setMsg("错误");
        result.setData(null);
        return  result;
    }
}
